<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
  const num = 4
  // const reg = /^([1-9]\d*|0)\.{0,1}\d{0,2}$/
  const reg = eval("/^([1-9]\\d*|0)\\.{0,1}\\d{0," + num + "}$/")
  console.log(reg.test(123.2222));
</script>
</body>
</html>
